package org.hackystat.iw.projectoverviewer.page.defaultmetrics;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * A model wrapper for the metrics instances.
 * 
 * @author Jianfei Liao
 */
public class MetricModel implements Serializable {
  /** Support serialization. */
  private static final long serialVersionUID = 1L;
  /** The strategy metric instance. */
  Metric strategy;
  /** The color provider metric instance. */
  Metric colorProvider;
  /** The size metric instance. */
  Metric size;
  /** The color metric instance. */
  Metric color;

  /**
   * Returns the strategy metric instance.
   * 
   * @return The strategy metric instance.
   */
  public Metric getStrategy() {
      return this.strategy;
  }

  /**
   * Sets the strategy metric instance.
   * 
   * @param strategy The strategy metric instance.
   */
  public void setStrategy(Metric strategy) {
    this.strategy = strategy;
  }
  
  /**
   * Returns the color provider metric instance.
   * 
   * @return The color provider metric instance.
   */
  public Metric getColorProvider() {
    return this.colorProvider;
  }
  
  /**
   * Sets the color provider metric instance.
   * 
   * @param colorProvider The color provider metric instance.
   */
  public void setColorProvider(Metric colorProvider) {
    this.colorProvider = colorProvider;
  }
  
  /**
   * Returns the size metric instance.
   * 
   * @return The size metric instance.
   */
  public Metric getSize() {
    return this.size;
  }
  
  /**
   * Sets the size metric instance.
   *  
   * @param size The size metric instance.
   */
  public void setSize(Metric size) {
    this.size = size;
  }
  
  /**
   * Returns the color metric instance.
   * 
   * @return The color metric instance.
   */
  public Metric getColor() {
    return this.color;
  }
  
  /**
   * Sets the color metric instance.
   * 
   * @param color The color metric instance.
   */
  public void setColor(Metric color) {
    this.color = color;
  }
  
  /**
   * Generate the choices for the drop down list of each different metric.
   * 
   * @param type The type of metric.
   * @return A list of choices for the metric.
   */
  protected static ArrayList<Metric> getChoices(String type) {
    ArrayList<Metric> list = new ArrayList<Metric>();
    if ("strategy".equals(type)) {
      list.add(new Metric("Squarified", "0"));
      list.add(new Metric("Sorted Weight", "1"));
      list.add(new Metric("Slice", "2"));
      list.add(new Metric("Equal Weight", "3"));
    }
    else if ("colorProvider".equals(type)) {
      list.add(new Metric("Red to Green Linear", "0"));
      list.add(new Metric("Red to Green Logarithmic", "1"));
      list.add(new Metric("Red to Green Square Root", "2"));
      list.add(new Metric("Red to Green Cube Root", "3"));
      list.add(new Metric("Random", "4"));
    }
    else if ("size".equals(type) || "color".equals(type)) {
      list.add(new Metric("Coverage", "1"));
      list.add(new Metric("LastEditedTime", "2"));
      list.add(new Metric("MethodsCount", "3"));
      list.add(new Metric("SourceLines", "4"));
    }
    
    return list;
  }
}
